package com.wenwei.net;


import com.wenwei.bean.ALiInfoBean;
import com.wenwei.bean.AllCouponBean;
import com.wenwei.bean.CityBean;
import com.wenwei.bean.ConfigBean;
import com.wenwei.bean.HaveSubscriberBean;
import com.wenwei.bean.HisPointBean;
import com.wenwei.bean.LoginBean;
import com.wenwei.bean.LookSuBean;
import com.wenwei.bean.MessageListBean;
import com.wenwei.bean.OrderInfoBean;
import com.wenwei.bean.ParkBean;
import com.wenwei.bean.ParkListBean;
import com.wenwei.bean.ParkingHistoryBean;
import com.wenwei.bean.RechargeBalanceBean;
import com.wenwei.bean.RechargeConfigBean;
import com.wenwei.bean.RegisterBean;
import com.wenwei.bean.SubscriberSuccBean;
import com.wenwei.bean.ThreadLoginBean;
import com.wenwei.bean.UserCouponBean;
import com.wenwei.bean.UserInfoBean;
import com.wenwei.bean.UserOrderEndBean;
import com.wenwei.bean.UserOrderingBean;
import com.wenwei.bean.UserParkBean;
import com.wenwei.bean.WalletHisBean;
import com.wenwei.bean.WeChatPayConfigBean;

import java.util.ArrayList;

import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Query;
import rx.Observable;

/**
 * Created by Bo on 2016/7/5.
 *
 * API请求接口
 *
 * 封装所有的请求API接口
 */
public interface ApiInterface {

    //注册-获取验证码
    @GET("app/sendSMS4Register")
    Observable<ApiResultBean<Object>> getRegisterSmsCode(@Query("phoneNum") String phone);

    //用户注册
    @POST("app/register")
    Observable<ApiResultBean<RegisterBean>> userRegister(@Body RequestBody body);

    //用户登录
    @FormUrlEncoded
    @POST("auth")
    Observable<ApiResultBean<LoginBean>> userLogin(@Field("username") String phone,
                                                   @Field("password") String code,
                                                   @Field("registrationId") String pw,
                                                   @Field("platform") String timeSpan);

    //忘记密码-获取验证码
    @GET("app/sendSMS4changePassword")
    Observable<ApiResultBean<Object>> getForgetSmsCode(@Query("phoneNum") String phone);

    //重置密码
    @POST("app/resetPassword")
    Observable<ApiResultBean<RegisterBean>> userReSetPassWord(@Body RequestBody body);

    //获取用户资料
    @GET("app/getUserFile")
    Observable<ApiResultBean<UserInfoBean>> getUserInfo(@Query("userId") int userId);

    //修改用户资料
    @POST("app/updateUserFile")
    Observable<ApiResultBean<Object>> updateUserPofile(@Body RequestBody body);


    //停车记录
    @GET("app/getParkLog")
    Observable<ParkingHistoryBean> getParkHistory(@Query("userId") int userId,
                                                  @Query("pageNum") int page);

    //发票可开金额
    @GET("app/getUsableInvoiceAmount")
    Observable<ApiResultBean<Double>> getUsableInvoiceAmount(@Query("userId") int userId);

    //索要发票
    @POST("app/addInvoice")
    Observable<ApiResultBean<Object>> addInvoice(@Body RequestBody body);

    //用户优惠券
    @GET("app/getUserCoupon")
    Observable<ApiResultBean<ArrayList<UserCouponBean>>> getUserCoupon(@Query("userId") int userId);

    //优惠券列表
    @GET("app/getCoupon")
    Observable<ApiResultBean<ArrayList<AllCouponBean>>> getCoupon(@Query("userId") int userId);

    //领取优惠券
    @POST("app/addUserCoupon")
    Observable<ApiResultBean<Object>> addUserCoupon(@Body RequestBody body);

    //钱包流水
    @GET("app/getWalletLog")
    Observable<WalletHisBean> getWalletLog(@Query("userId") int userId,
                                           @Query("pageNum") int page);

    //充值配置
    @GET("app/getRechargeCfg")
    Observable<ApiResultBean<ArrayList<RechargeConfigBean>>> rechargeConfig();

    //充值余额
    @POST("app/userRecharge")
    Observable<ApiResultBean<WeChatPayConfigBean>> recharges(@Body RequestBody body);

    //充值余额
    @POST("app/userRecharge")
    Observable<ApiResultBean<String>> rechargesAli(@Body RequestBody body);

    @GET("pay/wxpay")
    Observable<ApiResultBean<WeChatPayConfigBean>> wxPayConfig(@Query("outtradeno") String orderNum);

    //支付宝支付
    @GET("pay/alipay")
    Observable<ApiResultBean<String>> alipayConfig(@Query("outtradeno") String orderNum);

    //历史停车点
    @GET("app/getHistoryParkAddr")
    Observable<ApiResultBean<ArrayList<HisPointBean>>> getHistoryParkAddr(@Query("userId") int userId);

    //消息列表
    @GET("app/getMessageByUserId")
    Observable<MessageListBean> getMessageList(@Query("userId") int userId,
                                               @Query("pageNum") int page);


    //开锁使用
    @POST("app/addOrder")
    Observable<ApiResultBean<Object>> addOrder(@Body RequestBody body);

    //预约开锁
    @GET("app/openSubscribeParkCar")
    Observable<ApiResultBean<UserOrderingBean>> openSubscribeParkCar(@Query("subscribeId") int body);

    //预约订单
    @POST("app/addSubscribeOrder")
    Observable<ApiResultBean<SubscriberSuccBean>> addSubscribeOrder(@Body RequestBody body);

    //取消预约订单
    @GET("app/cancelSubById")
    Observable<ApiResultBean<Object>> cancelSubById(@Query("id") int orderId);

    //查询用户已有预约订单
    @GET("app/getUserExistSubByUserId")
    Observable<ApiResultBean<HaveSubscriberBean>> getUserExistSubByUserId(@Query("userId") int userId);

    //查询用户进行中的订单
    @GET("app/getOnGoingOrder")
    Observable<ApiResultBean<UserOrderingBean>> getOnGoingOrder(@Query("userId") int userId);

    //订单结束计费
    @POST("app/endCharge")
    Observable<ApiResultBean<UserOrderEndBean>> endCharge(@Body RequestBody body);

    //订单支付
    @POST("app/payOrder")
    Observable<ApiResultBean<WeChatPayConfigBean>> payOrder(@Body RequestBody body);

    //订单支付
    @POST("app/payOrder")
    Observable<ApiResultBean<String>> payOrderAli(@Body RequestBody body);

    //订单支付
    @POST("app/payOrder")
    Observable<ApiResultBean<Object>> payOrderYu(@Body RequestBody body);

    //获取停车场
    @GET("app/getCityAndPark")
    Observable<CityBean> getCityAndPark();

    //获取停车位
    @GET("app/getParkCar4user")
    Observable<ApiResultBean<ArrayList<ParkBean>>> getParkCar4user(@Query("longitude") String lng,
                                                                   @Query("latitude") String lat);

    //订单信息
    @GET("app/getOrderInfoById")
    Observable<ApiResultBean<OrderInfoBean>> getOrderInfo(@Query("orderId") int orderId);

    @GET("app/getParkCar4parkAdmin")
    Observable<ParkListBean> getParkList(@Query("userId") int userId,
                                                        @Query("parkId") int parkId,
                                                        @Query("pageNum") int page);

    @PUT("app/openParkCar")
    Observable<ApiResultBean<Object>> operatePark(@Query("parkCarId") int carId);

    @GET("app/getParkByParkAdmin")
    Observable<ApiResultBean<ArrayList<UserParkBean>>> getUserAdmin(@Query("parkAdminId") int userId);

    @POST("app/addAllege")
    Observable<ApiResultBean<Object>> addAllege(@Body RequestBody body);

    @GET("app/getAllegeByOrderId")
    Observable<ApiResultBean<LookSuBean>> getAllegeByOrderId(@Query("orderId") int orderId);

    @GET("auth/getConfig")
    Observable<ApiResultBean<ConfigBean>> getConfig();

    @GET("auth/threeLogin")
    Observable<ApiResultBean<LoginBean>> threadLogin(@Query("threeToken") String token);

    //支付宝三方登录签名
    @GET("auth/getInfoStr")
    Observable<ApiResultBean<String>> getALiLoginConfig();

    //三方登录完善信息
    @FormUrlEncoded
    @POST("auth/threeUpdateUser")
    Observable<ApiResultBean<Object>> bindInfo(@Field("threeToken") String token,
                                               @Field("username") String userPhone,
                                               @Field("password") String pw,
                                               @Field("verifyCode") String code,
                                               @Field("nikename")String nick,
                                               @Field("avator") String av,
                                               @Field("registrationId") String id,
                                               @Field("platform") String plat);

    //支付宝三方登录资料获取
    @GET("auth/getUserByAuthCode")
    Observable<ApiResultBean<ALiInfoBean>> getAuthInfo(@Query("auth_code") String code);

    //意见反馈
    @POST("app/addOpinion")
    Observable<ApiResultBean<Object>> addOpinion(@Body RequestBody body);

}







